package com.jekun.helloworld.designmode.memento.demo1;

/**
 * @author Administrator
 */
public class Client {
    public static void main(String a[]) {
        UserInfoDTO user = new UserInfoDTO();
        Caretaker caretaker = new Caretaker();

        user.setAccount("zhangsan");
        user.setPassword("123456");
        user.setTelNo("13000000000");
        System.out.println("状态一：");
        user.show();
        //保存备忘录
        caretaker.setMemento(user.saveMemento());
        System.out.println("---------------------------");

        user.setPassword("111111");
        user.setTelNo("13100001111");
        System.out.println("状态二：");
        user.show();
        System.out.println("---------------------------");

        //从备忘录中恢复
        user.restoreMemento(caretaker.getMemento());
        System.out.println("回到状态一：");
        user.show();
        System.out.println("---------------------------");
    }
}